<?php
/**
 * Created by PhpStorm.
 * User: 丶晓
 * Date: 2017/9/30
 * Time: 16:42
 */

namespace app\api\service;


use app\api\model\DataModel;
use app\api\model\MiniappsModel;
use app\api\model\PayModel;
use think\Validate;

class DataService extends DataModel
{
    public function Template($template_id)
    {
        if (empty($template_id) and $template_id != 0) {
            return false;
        }
        $Model = new MiniappsModel();
        return $Model->selectInfo('templateInfo', ['template_id' => $template_id]);
    }

    public function isBuyTemplate($uid, $template_id)
    {
        if (empty($uid) or empty($template_id)) {
            return false;
        }
        $Model = new PayModel();
        return $Model->selectInfo('user_got_tempalte', ['template_id' => $template_id, 'uid' => $uid, 'is_pay' => 1]);
    }

    public function getMiniappsPayDatas($type, $data = [])
    {
        switch ($type) {
            case 'getAllMchPayFile':
                return $this->selectInfo('miniapp_pay_file', ['id' => $data['miniID']]);
                break;
            case 'getAppid_miniID':  //  $data['miniID']
                return $this->selectInfo('appid_miniID', ['id' => $data['miniID']]);
                break;
        }
        return false;
    }

    public function saveFromUserSendMessage($type, $data = [])
    {
//        userMessage
    }

}






































